package 共享锁;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchDemo3 {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(10);
        for (int i = 0; i < 10; i++) {
            final int num = i + 1;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println("第" + num + "名");
                    countDownLatch.countDown();//线程数加1
                }
            }).start();
        }
        countDownLatch.await();
        System.out.println("比赛结束");
    }
}
